package com.atguigu.Mapper;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class NLineMapper extends Mapper<LongWritable, Text, Text, LongWritable> {

    private Text k = new Text();
    private LongWritable v = new LongWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException{

        String line = value.toString();

        String[] splited = line.split(" ");

        for (int i = 0; i < splited.length;i++) {
            k.set(splited[i]);

            context.write(k,v);
        }
    }
}
